﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using CoreModel = PlayerScannerCore.Model;
using Mvvm;
using PlayerScannerCore.Model;

namespace PlayerScannerCore.ViewModel
{
    public class UnitViewModel : ItemViewModel, IUnit
    {
        private int _kills;

        internal UnitViewModel()
        {
            ItemType = ItemType.Unit;
        }

        internal override void Update(IItem item)
        {
            var unit = (IUnit)item;

            Kills = unit.Kills;

            base.Update(unit);
        }

        public int Kills
        {
            get { return _kills; }
            set
            {
                if (_kills != value)
                {
                    _kills = value;
                    OnPropertyChanged("Kills");
                }
            }
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int hash = 23;
                hash = hash * 29 + Kills.GetHashCode();
                return hash * 29 + base.GetHashCode();
            }
        }

        public override bool Equals(object obj)
        {
            var objAsSpecific = obj as UnitViewModel;

            if (objAsSpecific == null)
                return false;

            if (ReferenceEquals(this, obj))
                return true;

            return objAsSpecific.Kills == Kills
                && base.Equals(obj);
        }
    }
}
